Collaborating:
You and your collaborators (including your
future self) can access the code and its history
Reproducible:
Your code runs and reproduces identical results
at different time points and on different systems
Colloquium | 13/01/2021
You and your collaborators (including your
future self) can access the code and its history
Your code runs and reproduces identical results
at different time points and on different systems
here-package (Müller, 2020) to define relative paths within the project: read.csv(here::here("data", "file_I_want.csv"))knitr (Xie, 2015, 2020) and tinytex (Xie, 2015, 2020; for pdfs)install.packages("rmarkdown")install.packages("rmarkdown")install.packages("rmarkdown")
knitr-package (Xie, 2014, 2015, 2020) to customize chunks and knitting process
{r cache=TRUE,message=FALSE,warning=FALSE,results="hide", error = TRUE}opts_chunk$set()-functionTinyTeX (Xie, 2010) is a light-weight, cross-platform distribution (install.packages("tinytex"); tinytex::install_tinytex()))install.packages() to install packages in this local libraryrenv.lock fileinstall.packages(renv)renv::init()renv::snapshot()renv::restore()renv::init()renv.lock fileinstall.packages("cowsay")
.Rmd files):cowsay::say("Hello world", "cow")
renv::snapshot()Restoring someone else’s package versions:
projectname.Rproj file)renv::restore() to install the package versions from the renv.lock fileN:/).Rmd files) on this virtual systemDockerfile that can be shared via GitHubdocker run -d -e PASSWORD=1234 -p 8787:8787 -v /path/to/your/project:/home/rstudio/ rocker/rstudio
Dockerfile in your project directy, specyfing additional steps to execute when building the container, e.g., install.packages("renv"); renv::restore()# This as a text file stored with the name "Dockerfile" in your project directory.
# Base image from Docker Hub, including R, RStudio, the tidyverse, and LaTeX
FROM rocker/verse:4.0.2
# Set working directory within the container
WORDIR /home/rstudio
# Install renv
RUN R -e "remotes::install_version('renv', version = '0.12.0', repos = 'http://cran.us.r-project.org')"
# Copy the lock file
COPY renv.lock renv.lock
# Install package versions stored in the lockfile
RUN R -e "renv::consent(provided = TRUE)"
RUN R -e "renv::restore(prompt = FALSE)"
Dockerfile for you if you don’t have your own one